package com.ericsson.rm.dao;

import java.util.List;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Query;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import com.ericsson.rm.model.RoleDetail;

@Repository
public class RoleDetailDaoImpl implements RoleDetailDao {

	@Autowired
	EntityManagerFactory factory;

	@SuppressWarnings("unchecked")
	public List<RoleDetail> fetchRoleDetail() {
		EntityManager entity = factory.createEntityManager();
		Query q = entity.createNamedQuery("RoleDetail.findAll",
				RoleDetail.class);
		return q.getResultList();
	}


	public String fetchRoleIdByRoleName(String roleName) {
		EntityManager entity = factory.createEntityManager();
		Query q = entity.createNamedQuery("RoleDetail.findId",RoleDetail.class);
		return q.toString();

	}

}
